class Shop::ChatMessagesController < ShopController
  def create
    @chat_message = ChatMessage.new chat_message_params
    if @chat_message.save
      redirect_to shop_shop_chat_chat_window_path(@chat_message.chat_window.shop_chat, @chat_message.chat_window), notice: "发送成功."
    else
      redirect_to shop_shop_chat_chat_window_path(@chat_message.chat_window.shop_chat, @chat_message.chat_window), notice: "发送失败."
    end
  end

  private

  def chat_message_params
    params.require(:chat_message).permit(:chat_window_id, :messageable_id, :messageable_type, :content)
  end
  
end
